subroutine prnres(nlog,nout)
  use param
  use global
  implicit none
  integer,intent(in) :: nlog,nout
  real(dbl) :: sum0,sum1
  integer :: i
  sum0=0
  do i=1,max_grid
     sum0=sum0+res(i)
  end do
  write(nlog,'(3x,"Sum of R(T), before=",1pe9.3,1x,"after=",1pe9.3)') sum_rspec,sum0
  open(unit=nout,file=outfn,status='replace')
  sum1=0
  write(nout,*) max_grid
  write(nlog,'(3x,"!-----------------------------------------!")') 
  write(nlog,'(3x,"Number of grid=",i0)') max_grid
  do i=1,max_grid
     rspec2(i)=res(i)/sum0
     sum1=sum1+rspec2(i)
     write(nout,'(3x,1pe11.5,1x,1pe11.5,1x,1pe11.5,1x,1pe11.5,1x,1pe11.5,1x,1pe11.5)') &
          egrid(i),egrid(i+1),res(i),rspec2(i),res(i)/(egrid(i+1)-egrid(i)),sum1
     write(nlog,'(3x,1pe11.5,1x,1pe11.5,1x,1pe11.5,1x,1pe11.5,1x,1pe11.5,1x,1pe11.5)') &
          egrid(i),egrid(i+1),res(i),rspec2(i),res(i)/(egrid(i+1)-egrid(i)),sum1
  end do
  close(nout)
end subroutine prnres
